<!--
 * @Author: shenya
 * @Date: 2023-08-08 10:03:49
 * @Description: 任务反馈
-->
<template>
  <basic-container>
    <avue-crud
      ref="crud"
      v-model="form"
      :page.sync="page"
      :data="tableData"
      :table-loading="tableLoading"
      :option="tableOption"
      :before-open="beforeOpen"
      @on-load="getList"
      @search-change="searchChange"
      @search-reset="searchReset"
    >
      <template
        slot="menu"
        slot-scope="scope"
      >
        <el-button
          type="text"
          size="small"
          icon="el-icon-edit"
          @click="taskview(scope.row, scope.index)"
        >任务清单
        </el-button>
      </template>
    </avue-crud>
    <todolist
      v-if="listVisible"
      :id="id"
      v-model="listVisible"
      @success="(val) => getList(page, val)"
    ></todolist>
  </basic-container>
</template>

<script>
import { getFeedbackList } from '@/api/core/feedback';
import { tableOption } from '@/const/crud/follow/feedback';
import { mapGetters } from 'vuex';
import crudMixins from '@/mixins/crud';
import todolist from './components/todolist.vue';
export default {
  name: 'customerManage',
  components: { todolist },
  mixins: [crudMixins],
  data() {
    return {
      editVisible: false,
      listVisible: false,
      form: {},
      tableOption: tableOption(),
      userId: null,
      addVisible: false,
      id: '',
    };
  },
  computed: {
    ...mapGetters(['permissions']),
  },
  watch: {},
  methods: {
    taskview(row) {
      this.id = row.id;
      this.listVisible = true;
    },
    // 列表查询
    getList(page, refresh) {
      if (refresh) {
        this.page.current = 1;
        this.page.currentPage = 1;
      }
      this.tableLoading = true;
      getFeedbackList(
        Object.assign(
          {
            current: this.page.currentPage,
            size: this.page.pageSize,
          },
          this.searchForm
        )
      )
        .then((response) => {
          this.tableData = response.data.data.records;
          this.page.total = response.data.data.total;
          this.tableLoading = false;
        })
        .catch(() => {
          this.tableLoading = false;
        });
    },
    // 打开前的拦截
    async beforeOpen(done, type) {},
  },
};
</script>
